﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Index.aspx.cs" Inherits="BuXiaChu.OrderDishes.Web.ServiceStation.Index" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/Blueprint/screen.css" />
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/Blueprint/print.css" />
    <link media="screen, projection" rel="stylesheet" type="text/css" href="/css/main.css" />

    <script type="text/javascript" src="js/Extend.js"></script>

    <script type="text/javascript" src="js/Common.js"></script>

    <script type="text/javascript" src="js/jquery-vsdoc.js"></script>

</head>
<body>
    <form id="form1" runat="server">
    <div class="container">
        <div class="span-24 boxc">
            Top
        </div>
        <div class="span-24 last boxc">
            <div>
                <span>订单编号</span><input type="text" id="txt_OrderId" />
                <span>送餐员</span>
                <select runat="server" id="sel_Employees">
                </select>
                <span>送餐地址</span><input type="text" id="txt_Address" />
                <span>来电</span><input type="text" id="txt_CallerId" />
                <input type="button" id="btn_Search" value="查询" />
                <hr />
                <input type="button" id="btn_Search_No" value="未处理" />
                <input type="button" id="btn_Search_All" value="全部" />
            </div>
            <div class="span-12 boxc">
                <div id="div_List" style="overflow: auto; height: 400px;">
                </div>
            </div>
            <div class="span-11 boxc">
                <div id="div_OrderDetails">
                    Details
                </div>
            </div>
        </div>
        <div class="span-24">footer</div>
    </div>
    </form>
</body>
</html>

<script type="text/javascript" src="js/PagePromptBox.js"></script>

<script type="text/javascript">
    var _employeeList_ = [];
    function getEmployeeList() {
        $.post("List.ashx", { t: 3 },
            function(data) {
                if (data.success) {
                    _employeeList_ = data.obj;
                    //                    var emp = jDoc("sel_Employees");
                    //                    emp.options[0] = new Option("--请选择--", "-1");
                    //                    for (var i = 0, dLen = data.obj.length; i < dLen; i++) {
                    //                        var obj = data.obj[i];
                    //                        emp.options[i + 1] = new Option(obj["name"], obj["id"]);
                    //                    }
                }
            }, "json");
    }

    function getOrderList(status) {
        var postData = { t: 1 };
        postData.orderId = jDoc("txt_OrderId").value.trim();
        postData.address = jDoc("txt_Address").value.trim();
        postData.callerId = jDoc("txt_CallerId").value.trim();
        var emp = jDoc("sel_Employees")
        postData.empId = emp.options[emp.selectedIndex].value;
        postData.status = status == undefined ? 1 : status;
        $.post("List.ashx", postData,
            function(data) {
                if (data.success) {
                    jDoc("div_List").innerHTML = data.message;
                } else {
                    jDoc("div_List").innerHTML = "查询失败，请刷新页面重新查询";
                }
            }, "json");
    }

    (function() {
        getEmployeeList();
        getOrderList();
        $(jDoc("btn_Search")).click(function() {
            getOrderList();
        });
        $(jDoc("btn_Search_No")).click(function() {
            getOrderList(1);
        });
        $(jDoc("btn_Search_All")).click(function() {
            getOrderList();
        });
    })();

    function assignOrder(id) {
        var html = [];
        html.push("<div>");
        html.push("<label>选择送餐员：</label>");      
        html.push("<select id='sel_Layer_EmpList'>");
        for (var i = 0, len = _employeeList_.length; i < len; i++) {
            html.push("<option");
            html.push(" value='" + _employeeList_[i].id + "'>");
            html.push(_employeeList_[i].name);
            html.push("</option>");
        }
        html.push("</select>");
        html.push("&nbsp;");
        html.push(jDoc.createInputHtml({ type: "button", id: "btn_Layer_OK", onclick: "alert(1)", value: "确定" }));
        html.push("&nbsp;");
        html.push(jDoc.createInputHtml({ type: "button", id: "btn_Layer_Cancle", onclick: "webPB.close();", value: "取消" }));
        html.push("</div>");
        webPB.showDialog(html.join(""));
    }
    function sendMessage(id) {
        window.open("Message.aspx?id=" + id);
    }
    function printOrder(id) {

    }
    function getOrderItemDetails(orderId) {
        if (orderId > 0) {
            $.post("List.ashx", { t: 2, orderId: orderId },
            function(data) {
                if (data.success) {
                    jDoc("div_OrderDetails").innerHTML = data.message;
                } else {
                    alert("Fail")
                }
            }, "json")
        }
    }
</script>

